<?php
/*
** date : 2011-2-18 ; copyright : 7OUR.COM <http://7our.com> ; author : xjay <xucj21@21cn.com>
*/
class AuthAction extends Action {
	protected $userid = null;
	protected $options = null;//系统配置
	protected $setting = null;//用户设置
	public function _initialize(){
		$user = Api('User');
		$this->options = Api('Option')->getWebOptions();
		if(!$this->options['allow_guest']){
			if($user->isLogin()){
				$this->userid = $user->getLoginUserId();
				
				//获取用户设置
				if(empty($this->setting)) $this->setting = Api('Option')->getUserSetting($this->userid);
				//皮肤主题
				if(isset($this->setting['user_theme'])){
		    		$site_theme = $this->setting['user_theme'];
		    		//@todo:个人定义皮肤设置
		    	}else{
		    		$site_theme = $this->options['site_theme'];
		    	}
		    	
			}else{
				redirect(C('WEB_URL').'pub/login');
			}
		}else{
			//@todo:游客设置
		}
		$site_theme = isset($this->setting['user_theme'])&&$this->setting['user_theme']!='user_diy'?$this->setting['user_theme']:isset($this->options['site_theme'])&&$this->options['site_theme']!=''?$this->options['site_theme']:'default';
		//模板解析变量设置
		$parse['__U__'] = C('WEB_URL');
		$parse['__T__'] = __ROOT__.'/'.C('THEME_DIR').'/'.$site_theme;
		C('TMPL_PARSE_STRING',$parse);
	}
}